package com.nineclock.auth.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.oauth2.provider.token.store.InMemoryTokenStore;
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;

/**
 * token存储
 * 令牌存储配置
 */
@Configuration
public class TokenConfig {
    private static final String SING_KEY="6A2811E15281EC7A4EB20088A7B0645A";

    @Bean
    public JwtAccessTokenConverter jwtAccessTokenConverter(){
        JwtAccessTokenConverter tokenConverter=new JwtAccessTokenConverter();
        //设置密钥
        tokenConverter.setSigningKey(SING_KEY);
        return tokenConverter;
    }

    @Bean
    public TokenStore tokenStore(){
        //在内存中存储token(简单的令牌)
        return new InMemoryTokenStore();
    }
}